/* to create reminder nodes & card nodes */

import { Homepage_Card, Homepage_Reminder } from './hp_card.js';
import { vns_method_to_btn_name } from './anicard.js';

const homepage_vns_url = "./assets/json/vns_collection.json";
const homepage_cards_url = "./assets/json/anicard_dataset.json";
const card_display_nodeList = [];
const card_single_nodeList = [];

$.getJSON(homepage_vns_url, json => {

    json.forEach((json_item, i, jsonArr) => {
        let card_display_single_node = document.createElement("div");
        let card_deck_node = document.createElement("div");
        card_display_single_node.classList.add(json_item["VNS_tag"] + "");
        card_deck_node.classList.add("row", "row-cols-1", "row-cols-sm-2", "row-cols-lg-3", "card-deck");
        card_display_single_node.appendChild(card_deck_node);

        let display_reminder_subject = new Homepage_Reminder({
            VNS_tag: json_item["VNS_tag"],
            VNS_desc: json_item["VNS_desc"],
            VNS_num: json_item["VNS_num"]
        });
        display_reminder_subject.appendTo(card_display_single_node, card_deck_node, vns_method_to_btn_name);
        card_display_nodeList.push(card_display_single_node);
    });
});


$.getJSON(homepage_cards_url, json => {

    json.forEach((json_item, i, jsonArr) => {
        let card_single_subject = new Homepage_Card(json_item);
    })
});

export { 
    card_display_nodeList as card_display_nodeList, 
    card_single_nodeList as card_single_nodeList
};